import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import Params from '@/components/Params'
import Hi1 from '@/components/Hi1'
import Error from '@/components/Error'

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [{
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld,
      alias: 'Home1'
      // PATH /  起别名是没用的
    },
    {
      path: '/params/:newsId(\\d+)/:newsTitle',
      component: Params,
      // beforeEnter: (to, from, next)=>{
      //   console.log('我进入了Params模板')
      //   console.log(to);
      //   console.log(from);
      //   // next({path:'/'});
      //   next();//next很强大，进入路由的“防线”
      // }
    },
    {
      path: '/gohome',
      redirect: '/'
    },
    {
      path: '/goparams/:newsId(\\d+)/:newsTitle',
      redirect: '/params/:newsId(\\d+)/:newsTitle'
    }, {
      path: '/Hi1',
      name: 'Hi1',
      component: Hi1,
      alias: '/jspang'
    }, {
      path: '*',
      component: Error
    }
  ]
})
